﻿package BasicData
{
	public class Skill
	{
		public var skillname:String;
		public var keyability:String;
		public var description:String;
		private var skillmods:Array;
		public var total:int;
		function CalcTotal():void{
			var temp:int = 0;
			for (i=0; i<skillmods.length; i++){
				temp += skillmods[i].modvalue;
			}
			total = temp;
		}
		function AddMod(t:String, d:String, m:int){
			Modifier newmod = new Modifier(t,d,m);
			skillmods.push(newmod);
			skillmods.sort();
		}
		function ModifyMod(t:String, m:int){
			for (i=0; i<skillmods.length; i++){
				if (skillmods[i].modtype == t){
					skillmods[i].modvalue = m;
				}
			}
		}
		function Skill(n:String, keyab:String, desc:String, abilitymod:int, train:Boolean, power:Boolean, feat:Boolean){
			skillname = n;
			keyability = keyab;
			description = desc;
			AddMod("Ability", "Ability modifier", abilitymod);
			AddMod("Trained", "Trained or not", train);
			AddMod("Power", "Power bonus", power);
			AddMod("Feat", "Feat bonus", feat);
			CalcTotal();
		}
	}
}